package com.ruoyi.blsj.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.blsj.domain.BlsjHzxx;
import com.ruoyi.blsj.service.IBlsjHzxxService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 患者信息Controller
 * 
 * @author ruoyi
 * @date 2023-10-10
 */
@Controller
@RequestMapping("/blsj/hzxx")
public class BlsjHzxxController extends BaseController
{
    private String prefix = "blsj/hzxx";

    @Autowired
    private IBlsjHzxxService blsjHzxxService;

    @RequiresPermissions("blsj:hzxx:view")
    @GetMapping()
    public String hzxx()
    {
        return prefix + "/hzxx";
    }

    /**
     * 查询患者信息列表
     */
    @RequiresPermissions("blsj:hzxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BlsjHzxx blsjHzxx)
    {
        startPage();
        List<BlsjHzxx> list = blsjHzxxService.selectBlsjHzxxList(blsjHzxx);
        return getDataTable(list);
    }

    /**
     * 导出患者信息列表
     */
    @RequiresPermissions("blsj:hzxx:export")
    @Log(title = "患者信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BlsjHzxx blsjHzxx)
    {
        List<BlsjHzxx> list = blsjHzxxService.selectBlsjHzxxList(blsjHzxx);
        ExcelUtil<BlsjHzxx> util = new ExcelUtil<BlsjHzxx>(BlsjHzxx.class);
        return util.exportExcel(list, "患者信息数据");
    }

    /**
     * 新增患者信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存患者信息
     */
    @RequiresPermissions("blsj:hzxx:add")
    @Log(title = "患者信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BlsjHzxx blsjHzxx)
    {
        return toAjax(blsjHzxxService.insertBlsjHzxx(blsjHzxx));
    }

    /**
     * 修改患者信息
     */
    @RequiresPermissions("blsj:hzxx:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BlsjHzxx blsjHzxx = blsjHzxxService.selectBlsjHzxxById(id);
        mmap.put("blsjHzxx", blsjHzxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存患者信息
     */
    @RequiresPermissions("blsj:hzxx:edit")
    @Log(title = "患者信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BlsjHzxx blsjHzxx)
    {
        return toAjax(blsjHzxxService.updateBlsjHzxx(blsjHzxx));
    }

    /**
     * 删除患者信息
     */
    @RequiresPermissions("blsj:hzxx:remove")
    @Log(title = "患者信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(blsjHzxxService.deleteBlsjHzxxByIds(ids));
    }
}
